﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="../js/editor/xheditor-1.1.14-zh-cn.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        var id = "0";
        $(document).ready(function () {
            $("#txtContent").xheditor({ forcePtag: false, tools: 'full', upLinkUrl: "uploadTongzhi.aspx", upLinkExt: "zip,rar,txt", upImgUrl: "uploadTongzhi.aspx", upImgExt: "jpg,jpeg,gif,png", upFlashUrl: "uploadTongzhi.aspx", upFlashExt: "swf", upMediaUrl: "uploadTongzhi.aspx", upMediaExt: "avi" });


            var reg = new RegExp("(^|&)ID=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                id = unescape(r[2]);
            }
            if (id != "0") {
                $.ajax({ url: "ashx/addSaishi.ashx",
                    cache: false,
                    dataType: "json",
                    data: { "id": id, "type": "selectid" },
                    type: "post",
                    success: function (data) {
                        if (data.length == 0) {
                            return;
                        }
                        $("#txtTitle").val(data[0].title);
                        $("#txtContent").val(data[0].content);
                    }
                });
            }

            $("#btnClose").click(function () {
                window.returnValue = "";
                window.close();
            });

            $("#btnSubmit").click(function () {
                if ($("#txtTitle").val() == "") {
                    alert("请输入标题！");
                    $("#txtTile").focus();
                    return false;
                }
                if ($("#txtContent").val() == "") {
                    alert("请输入内容");
                    $("#txtContent").focus();
                    return false;
                }

                var type = "insert";
                if (id != "0") {
                    type = "update";
                }
                $.ajax({ url: "ashx/addSaishi.ashx",
                    cache: false,
                    dataType: "json",
                    data: { "id": id, "Title": $("#txtTitle").val(), "Content": $("#txtContent").val(), "type": type },
                    type: "post",
                    success: function (data) {
                        window.returnValue = "1";
                        window.close();
                    }
                });
            });
        });

    </script>
    <style type="text/css">
        .style1
        {
            width: 20px;
        }
        .style2
        {
            width: 20px;
            height: 10px;
        }
        .style3
        {
            height: 10px;
        }
    </style>
</head>
<body>
    <div>
        <table>
            <tr>
                <td class="style2">
                </td>
                <td class="style3">
                </td>
                <td class="style3">
                </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;
                </td>
                <td>
                    <label for="Title">
                        标题：</label>
                </td>
                <td>
                    <input id="txtTitle" name="Title" type="text" />
                </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;
                </td>
                <td>
                    <label for="Content">
                        内容：</label>
                </td>
                <td>
                    <textarea id="txtContent" name="Content" cols="60" rows="20"></textarea>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;
                </td>
                <td>
                </td>
                <td style="text-align: right;">
                    <input id="btnSubmit" type="button" value="确定" />
                    &nbsp;&nbsp;<input id="btnClose" type="button" value="关闭" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
